<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://shiro.apache.org/tags" prefix="shiro" %>
<c:set var="contextPath" value="${pageContext.request.contextPath}"></c:set>


<title>烟草客户信息管理 - 云超市</title>

<style type="text/css">
    .customBtn {
        line-height: 20px;
        margin-bottom: 3px;
    }

    .btnLine {
        margin-left: 1px;
        margin-top: 8px;
        margin-bottom: 2px;
    }

    .autocomplete-suggestions {
        border: 1px solid #999;
        background: #FFF;
        overflow: auto;
    }

    .autocomplete-suggestion {
        padding: 2px 5px;
        white-space: nowrap;
        overflow: hidden;
    }

    .autocomplete-selected {
        background: #F0F0F0;
    }

    .autocomplete-suggestions strong {
        font-weight: normal;
        color: #3399FF;
    }

    @-moz-document url-prefix() {
        fieldset {
            display: table-cell;
        }
    }

</style>
<link rel="stylesheet" href="${contextPath}/static/ace/components/_mod/jquery-ui/jquery-ui.css"/>

<link rel="stylesheet"
      href="${contextPath}/static/ace/components/bootstrap-datepicker/dist/css/bootstrap-datepicker3.css"/>
<link rel="stylesheet" href="${contextPath}/static/ace/components/_mod/jqgrid/ui.jqgrid.css"/>

<%--<jsp:include page="../../head.jsp" />--%>

<div class="row">
    <div class="row btnLine">
        <div class="button-len col-sm-12">
            <form class="form-inline">
                <shiro:hasPermission name="CLOUDERPORDERSPLADMINORDER:STATISTICS">
                    <div class="form-group">
                        <input class="form-control input-sm" onfocus="this.value=''" type="text" id="quXianNameInput"
                               placeholder="区县名称">
                    </div>
                </shiro:hasPermission>
                <shiro:lacksPermission name="CLOUDERPORDERSPLEMPORDER:STATISTICS">
                    <shiro:lacksPermission name="CLOUDERPORDERSPLCHANNELORDER:STATISTICS">
                        <div class="form-group">
                            <input class="form-control input-sm" onfocus="this.value=''" type="text" id="quDaoNameInput"
                                   placeholder="渠道名称">
                        </div>
                    </shiro:lacksPermission>
                    <div class="form-group">
                        <input class="form-control input-sm" onfocus="this.value=''" type="text" id="KeHuJingLiNameInput"
                               placeholder="客户经理名称">
                    </div>
                </shiro:lacksPermission>
                <div class="form-group">
                    <input class="form-control input-sm" type="text" id="channelNameInput"
                           placeholder="客户名称">
                </div>
                <div class="form-group">
                    <input class="form-control input-sm" type="text" id="slsmanNameInput"
                           placeholder="专卖证号">
                </div>
                <div class="form-group">
                    <input id="cityTypeInput" class="form-control input-sm" type="text" placeholder="经营类型">
                </div>
                <div class="form-group">
                    <input id="orderLevelInput" class="form-control input-sm" type="text" placeholder="客户档位">
                </div>
                <div class="form-group">
                    <select id="timeTypeInput" class="form-control" style="height: 31px;">
                        <option value="CC.FIRST_BIND_CAR_TIME">绑卡</option>
                        <option value="CC.FIRST_PAY_ORDER_TIME">支付</option>
                        <option value="CC.FIRST_LOGIN_TIME">注册</option>
                    </select>
                    <input class="form-control input-sm" type="text" id="firstBindCarTimeInput"
                           placeholder="开始时间">
                    <input class="form-control input-sm" type="text" id="firstPayOrderTimeInput"
                           placeholder="结束时间">
                </div>

                <div class="form-group">
                    <select id="isBankCarInout" class="form-control" style="height: 31px">
                        <option value="-1">==是否绑卡==</option>
                        <option value="1">是</option>
                        <option value="0">否</option>
                    </select>
                </div>
                <div class="form-group">
                    <select id="isDingYanInout" class="form-control" style="height: 31px">
                        <option value="-1">==是否订烟==</option>
                        <option value="1">是</option>
                        <option value="0">否</option>
                    </select>
                </div>
                <div class="form-group">
                    <select id="isPayInout" class="form-control" style="height: 31px">
                        <option value="-1">==是否支付==</option>
                        <option value="1">是</option>
                        <option value="0">否</option>
                    </select>
                </div>
                <div class="form-group">
                    <select id="isExpInout" class="form-control" style="height: 31px" title="此查询结果为：试点店铺授权的烟草客户信息">
                        <option value="-1">==是否试点==</option>
                        <option value="1">是</option>
                        <option value="0">否</option>
                    </select>
                </div>
                <div class="form-group">
                    <select id="syncStateInput" class="form-control" style="height: 31px">
                        <option value="-1">==同步状态==</option>
                        <option value="1">已同步</option>
                        <option value="0">未同步</option>
                    </select>
                </div>
                <button type="button" class="btn btn-sm btn-white btn-info search-len customBtn"
                        onclick="searchCgtCust()">
                    <i class="ace-icon fa fa-search orange"></i>搜索
                </button>
                <button type="button" class="btn btn-sm btn-white btn-success search-len customBtn"
                        onclick="exportExcel()">
                    <i class="ace-icon fa fa-file-excel-o green"></i>导出
                </button>
                <shiro:hasPermission name="CLOUDERPORDERSPLEMPORDER:STATISTICS">
                    <button type="button" class="btn btn-white  btn-success btn-sm customBtn"
                            onclick="uploadExcelBindCar()" title="上传Excel批量绑卡">
                        <i class="glyphicon glyphicon-upload"></i>上传
                    </button>
                </shiro:hasPermission>
                <shiro:hasPermission name="CLOUDERPORDERSPLADMINORDER:STATISTICS">
                    <button type="button" class="btn btn-white  btn-success btn-sm customBtn"
                            onclick="uploadExcelBindCar()" title="上传Excel批量绑卡">
                        <i class="glyphicon glyphicon-upload"></i>上传
                    </button>
                </shiro:hasPermission>
            </form>
        </div>
    </div>
    <div class="col-xs-12">

        <table id="grid-table"></table>

        <div id="grid-pager"></div>

    </div>
</div>
<!-- 小云消息modal -->
<div class="modal fade" tabindex="-1" role="dialog" id="sendCloudingMessageModal">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">发送小云消息给：<span id="usernameSpan" style="color:red;"></span></h4>
                <input type="hidden" id="sendCloudingMessagePhone">
            </div>
            <div class="modal-body">
                <p style="color:green;" id="tishiP">输入消息内容：</p>
                <textarea rows="2" cols="50" id="sendCloudingMessagecontent"></textarea>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" id="confrimBtn" onclick="sendCloudingMessageConfrim()">
                    确定
                </button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>
<!-- /.modal -->

<!-- 客户相关信息modal -->
<div id="userInfoContent" class="hide">
    <ul class="nav nav-tabs" role="tablist">
        <li role="presentation" class="active"><a href="#home" aria-controls="home" role="tab"
                                                  data-toggle="tab">基本信息</a></li>
        <li><a href="#profile" data-toggle="tab">授权信息</a></li>
        <li><a href="#bankinfo" data-toggle="tab">绑卡信息</a></li>
    </ul>
    <!-- Tab panes -->
    <div class="tab-content" id="app">
        <div role="tabpanel" class="tab-pane active" id="home">
            <div class="widget-body">
                <div class="widget-main padding-24">
                    <div class="row">
                        <div class="col-sm-6">
                            <ul class="list-unstyled spaced">
                                <li>
                                    <i class="ace-icon fa fa-caret-right blue"></i><strong>机构名称：</strong>{{basicInfo.channelName}}
                                </li>

                                <li>
                                    <i class="ace-icon fa fa-caret-right blue"></i><strong>机构名称：</strong>{{basicInfo.orgCode}}
                                </li>

                                <li>
                                    <i class="ace-icon fa fa-caret-right blue"></i><strong>客户经理：</strong>{{basicInfo.slsmanName}}
                                </li>

                                <li>
                                    <i class="ace-icon fa fa-caret-right blue"></i><strong>客户名称：</strong>{{basicInfo.custName}}
                                </li>

                                <li>
                                    <i class="ace-icon fa fa-caret-right blue"></i><strong>专卖证号：</strong>{{basicInfo.custCode}}
                                </li>

                                <li>
                                    <i class="ace-icon fa fa-caret-right blue"></i><strong>密码：</strong>{{basicInfo.custPassword}}
                                </li>
                                <li>
                                    <i class="ace-icon fa fa-caret-right blue"></i><strong>商户名称：</strong>{{merchant.merchantName}}
                                </li>

                                <li>
                                    <i class="ace-icon fa fa-caret-right blue"></i><strong>客户地址：</strong>{{basicInfo.custAddr}}
                                </li>
                            </ul>
                        </div>

                        <div class="col-sm-6">
                            <ul class="list-unstyled spaced">
                                <li>
                                    <i class="ace-icon fa fa-caret-right green"></i><strong>订烟日：</strong>{{basicInfo.orderDateStr}}
                                </li>

                                <li>
                                    <i class="ace-icon fa fa-caret-right green"></i><strong>订烟起始时间：</strong>{{basicInfo.orderBeginTimeStr}}
                                </li>

                                <li>
                                    <i class="ace-icon fa fa-caret-right green"></i><strong>订烟结束时间：</strong>{{basicInfo.orderEndTimeStr}}
                                </li>

                                <li>
                                    <i class="ace-icon fa fa-caret-right green"></i><strong>下一订烟日：</strong>{{basicInfo.nextOrderDateStr}}
                                </li>

                                <li>
                                    <i class="ace-icon fa fa-caret-right green"></i><strong>订烟开始日期：</strong>{{basicInfo.beginDateStr}}
                                </li>

                                <li>
                                    <i class="ace-icon fa fa-caret-right green"></i><strong>订烟结束日期：</strong>{{basicInfo.endDateStr}}
                                </li>
                                <li>
                                    <i class="ace-icon fa fa-caret-right green"></i><strong>商户代码：</strong>{{merchant.merchantCode}}
                                </li>
                                <li>
                                    <i class="ace-icon fa fa-caret-right green"></i><strong>银行代码：</strong>{{merchant.bankCode}}
                                </li>

                            </ul>
                        </div>
                    </div><!-- /.col -->
                </div>
            </div>
        </div>

        <div role="tabpanel" class="tab-pane" id="profile">

            <div class="table-responsive">
                <table class="table table-bordered table-hover table-condensed">
                    <thead>
                    <tr>
                        <th>序号</th>
                        <th>姓名</th>
                        <th>手机号</th>
                        <th>授权状态</th>
                        <th>修改时间</th>
                        <th>创建时间</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr v-for=" (authorizationInfo, index) in authorizationInfoList">
                        <td>{{index+1}}</td>
                        <td>{{authorizationInfo.username}}</td>
                        <td>{{authorizationInfo.phone}}</td>
                        <td>{{authorizationInfo.stateStr}}</td>
                        <td>{{authorizationInfo.stateDateStr}}</td>
                        <td>{{authorizationInfo.createDateStr}}</td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>

        <div role="tabpanel" class="tab-pane" id="bankinfo">
            <!-- Button trigger modal -->
            <button type="button" class="btn btn-primary btn-sm" data-toggle="modal" @click="showBangKaModal">
                绑定银行卡
            </button>

            <!-- Modal -->
            <div class="modal fade" id="myModal" tabindex="-1" data-backdrop="static" role="dialog"
                 aria-labelledby="myModalLabel">
                <div class="modal-dialog" role="document">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                                    aria-hidden="true">&times;</span></button>
                            <h4 class="modal-title" id="myModalLabel">绑定银行卡</h4>
                        </div>
                        <div class="modal-body">
                            <form class="form-horizontal">
                                <div class="form-group">
                                    <label for="name" class="col-sm-2 control-label">持卡人</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" v-model="addBankInfo.name" id="name"
                                               placeholder="请输入持卡人姓名">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="certCode" class="col-sm-2 control-label">身份证</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" v-model="addBankInfo.certCode"
                                               id="certCode" placeholder="请输入身份证号码">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="accNo" class="col-sm-2 control-label">卡号</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" v-model="addBankInfo.accNo"
                                               @blur="selectBankInfo" id="accNo" placeholder="请输入银行卡号">
                                    </div>
                                </div>
                                <div class="form-group" v-show="addBankInfo.cardType !=''">
                                    <label for="bankName" class="col-sm-2 control-label">开户行</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" v-model="addBankInfo.bankName"
                                               id="bankName" placeholder="">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="nbr" class="col-sm-2 control-label">电话号码</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" v-model="addBankInfo.nbr" id="nbr"
                                               placeholder="请输入银行预留手机号">
                                    </div>
                                </div>
                                <div class="form-group" v-show="addBankInfo.cardType=='01'">
                                    <label for="expireDate" class="col-sm-2 control-label">有效期</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" v-model="addBankInfo.expireDate"
                                               id="expireDate" placeholder="月／年">
                                    </div>
                                </div>
                                <div class="form-group" v-show="addBankInfo.cardType=='01'">
                                    <label for="cvn2" class="col-sm-2 control-label">校验码</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" v-model="addBankInfo.cvn2" id="cvn2"
                                               placeholder="信用卡背面签名栏三位校验码">
                                    </div>
                                </div>


                            </form>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                            <button type="button" class="btn btn-primary" @click="submitAddBankCar">确定</button>
                        </div>
                    </div>
                </div>
            </div>

            <div class="table-responsive" style="margin-top: 10px;">
                <table class="table table-bordered table-hover table-condensed">
                    <thead>
                    <tr>
                        <th>序号</th>
                        <th>银行编号</th>
                        <th>银行名称</th>
                        <th>卡类型</th>
                        <th>卡号</th>
                        <th>卡号后四位</th>
                        <th>签约号</th>
                        <th>绑卡手机号</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr v-for=" (bankInfo, index) in bankInfoList">
                        <td>{{index+1}}</td>
                        <td>{{bankInfo.bankNo}}</td>
                        <td><img style="width: 20px;height: 20px; margin-right: 5px;"
                                 :src="'http://clouderp.combinedpay.cn:20081/'+bankInfo.bankIcon">{{bankInfo.bankName}}
                        </td>
                        <td><span v-if="bankInfo.cardType=='01'">贷记卡</span><span
                                v-if="bankInfo.cardType=='02'">借记卡</span></td>
                        <td>{{bankInfo.cardNo}}</td>
                        <td>{{bankInfo.last4}}</td>
                        <td>{{bankInfo.bindId}}</td>
                        <td>{{bankInfo.nbr}}</td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>


<!-- 上传文件区域 -->
<div id="uplaodExcelFileContent" style="text-align: center;" class="hide">
    <a style="margin-top: 25px;" href="${contextPath}/page/downLoadExcelTemplate"
       class="btn  btn-success btn-sm">下载模版</a>
    <input type="file" name="excelInput" style="margin-top: 20px;">
    <button type="button" class="btn  btn-primary btn-sm" onclick="uploadExcel()" title="上传Excel到后台">信息上传</button>
    <div style="margin-top: 30px;">
        <form action="${contextPath}/page/getUploadExcelResult" method="post" id="getUploadExcelResultForm">
            <input style="width:200px;" id="getResultFileNameInput" name="resultFileName" type="text"
                   placeholder="请输入要获取的文件名">
        </form>
    </div>
    <button style="margin-top: 20px;" type="button" class="btn  btn-info btn-sm" onclick="getUploadResult();"
            title="根据文件名获取上传结果">获取结果
    </button>
</div>

<!-- 导出Excel -->
<form action="${contextPath}/sys/clouderp/cgtCustInfoExportExcel" method="post" id="exportExcel" style="display:none">
    <input type="hidden" id="exportExcelData-filters" name="filters">
    <input type="hidden" name="tableType" value="stock">
</form>

<!-- page specific plugin scripts -->
<script type="text/javascript">
    var scripts = [null, "${contextPath}/static/ace/components/bootstrap-datepicker/dist/js/bootstrap-datepicker.js", "${contextPath}/static/ace/components/jqGrid/js/jquery.jqGrid.js", "${contextPath}/static/ace/components/jqGrid/js/i18n/grid.locale-cn.js", null]
    $('.page-content-area').ace_ajax('loadScripts', scripts, function () {

        jQuery(function ($) {
            var grid_selector = "#grid-table";
            var pager_selector = "#grid-pager";


            var parent_column = $(grid_selector).closest('[class*="col-"]');
            //resize to fit page size
            $(window).on('resize.jqGrid', function () {
                $(grid_selector).jqGrid('setGridWidth', parent_column.width());
            })

            //resize on sidebar collapse/expand
            $(document).on('settings.ace.jqGrid', function (ev, event_name, collapsed) {
                if (event_name === 'sidebar_collapsed' || event_name === 'main_container_fixed') {
                    //setTimeout is for webkit only to give time for DOM changes and then redraw!!!
                    setTimeout(function () {
                        $(grid_selector).jqGrid('setGridWidth', parent_column.width());
                    }, 20);
                }
            })

            //if your grid is inside another element, for example a tab pane, you should use its parent's width:
            /**
             $(window).on('resize.jqGrid', function () {
			var parent_width = $(grid_selector).closest('.tab-pane').width();
			$(grid_selector).jqGrid( 'setGridWidth', parent_width );
		})
             //and also set width when tab pane becomes visible
             $('#myTab a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
		  if($(e.target).attr('href') == '#mygrid') {
			var parent_width = $(grid_selector).closest('.tab-pane').width();
			$(grid_selector).jqGrid( 'setGridWidth', parent_width );
		  }
		})
             */





            jQuery(grid_selector).jqGrid({
                //direction: "rtl",

                //subgrid options
                subGrid: true,
                //subGridModel: [{ name : ['No','Item Name','Qty'], width : [55,200,80] }],
                subGridOptions: {
                    plusicon: "ace-icon fa fa-plus center bigger-110 blue",
                    minusicon: "ace-icon fa fa-minus center bigger-110 blue",
                    openicon: "ace-icon fa fa-chevron-right center orange"
                },
                //for this example we are using local data
                subGridRowExpanded: function (subgridDivId, rowId) {
                    var subgridTableId = subgridDivId + "_t";
                    $("#" + subgridDivId).html("<table id='" + subgridTableId + "'></table>");
                    $("#" + subgridTableId).jqGrid({
                        datatype: 'json',
                        //data: subgrid_data,
                        url: "${contextPath}/sys/clouderp/getSubCgtCustInfo?parentId=" + rowId,
                        colNames: ['', 'ID', '用户姓名', '手机号', '授权情况', '最近修改时间', '创建时间'],
                        colModel: [
                            {
                                name: 'myac', index: '', width: 80, fixed: true, sortable: false, resize: false,
                                editable: false,
                                search: false,
                                sortable: false,
                                formatter: changeCgtCust

                            },
                            {name: 'id', width: 50, hidden: true},
                            {name: 'username', width: 150},
                            {name: 'phone', width: 150},
                            {name: 'stateStr', width: 150},
                            {name: 'stateDateStr', width: 150},
                            {name: 'createDateStr', width: 150}
                        ],
                        jsonReader: {
                            root: "recordList",
                            page: "currentPage",
                            total: "pageCount",
                            records: "recordCount"
                        }
                    });
                },


                //data: grid_data,
                url: "${contextPath}/sys/clouderp/getCgtCustInfo",
                datatype: "json",
                mtype: 'POST',
                height: '300',
                colNames: ['', '客户ID', '机构名称', '机构代码', '客户经理', '客户名称', '客户地址', '专卖证号', '绑卡张数', '订单次数', '首次绑卡', '首次支付', '注册时间', '试点用户', '当日注册', '当日绑卡', '当日支付', '密码', '订烟日', '订烟起始时间', '订烟结束时间', '下一订烟日', '订烟开始日期', '订烟结束日期'],
                colModel: [
                    {
                        name: 'myac', index: '', width: 40, fixed: true, sortable: false, resize: false,
                        editable: false,
                        search: false,
                        sortable: false,
                        formatter: synchronizationUnionpay

                    },
                    {
                        name: 'id',
                        index: 'id',
                        width: 60,
                        sorttype: "int",
                        sortable: false,
                        hidden: true,
                        editable: true
                    },
                    {
                        name: 'channelName',
                        index: 'channelName',
                        width: 100,
                        sortable: true,
                        editable: true,
                        hidden: true,
                    },
                    {name: 'orgCode', index: 'orgCode', width: 80, editable: true, sortable: false, hidden: true},
                    {name: 'slsmanName', index: 'slsmanName', width: 60, sortable: false, editable: true, hidden: true},
                    {
                        name: 'custName',
                        index: 'custName',
                        width: 60,
                        sortable: false,
                        editable: true,
                        formatter: showUserInfo
                    },
                    {name: 'custAddr', index: 'custAddr', width: 60, sortable: false, editable: true,hidden: true},
                    {name: 'custCode', index: 'custCode', width: 80, sortable: false, editable: true},
                    {name: 'bankCarCount', index: 'bankCarCount', width: 50, sortable: true, editable: true},
                    {name: 'orderCOunt', index: 'orderCOunt', width: 50, sortable: true, editable: true},
                    {name: 'firstBindCarTime', index: 'firstBindCarTime', width: 50, sortable: true, editable: true},
                    {name: 'firstPayOrderTime', index: 'firstPayOrderTime', width: 50, sortable: true, editable: true},
                    {name: 'firstLoginTime', index: 'firstLoginTime', width: 50, sortable: true, editable: true},
                    {name: 'isShiDian', index: 'isShiDian', width: 50, hidden: true, sortable: false, editable: true},
                    {
                        name: 'isTodayRegister',
                        index: 'isTodayRegister',
                        width: 50,
                        hidden: true,
                        sortable: false,
                        editable: true
                    },
                    {
                        name: 'isTodayBindCar',
                        index: 'isTodayBindCar',
                        width: 50,
                        hidden: true,
                        sortable: false,
                        editable: true
                    },
                    {
                        name: 'isTodayPayOrder',
                        index: 'isTodayPayOrder',
                        width: 50,
                        hidden: true,
                        sortable: false,
                        editable: true
                    },

                    {
                        name: 'custPassword',
                        index: 'custPassword',
                        width: 50,
                        sortable: false,
                        editable: true,
                        hidden: true,
                    },
                    {
                        name: 'orderDateStr',
                        index: 'orderDateStr',
                        width: 80,
                        sortable: true,
                        editable: true,
                        hidden: true,
                    },
                    {
                        name: 'orderBeginTimeStr',
                        index: 'orderBeginTimeStr',
                        width: 70,
                        hidden: true,
                        sortable: false,
                        editable: true
                    },
                    {
                        name: 'orderEndTimeStr',
                        index: 'orderEndTimeStr',
                        width: 70,
                        hidden: true,
                        sortable: false,
                        editable: true
                    },
                    {
                        name: 'nextOrderDateStr',
                        index: 'nextOrderDateStr',
                        width: 70,
                        hidden: true,
                        sortable: false,
                        editable: true
                    },
                    {
                        name: 'beginDateStr',
                        index: 'beginDateStr',
                        width: 70,
                        hidden: true,
                        sortable: false,
                        editable: true
                    },
                    {name: 'endDateStr', index: 'endDateStr', width: 50, hidden: true, sortable: false, editable: true},

                ],
                sortname: "orderDateStr",
                sortorder: "desc",
                viewrecords: true,
                rowNum: 10,
                //rowList: [10, 20, 30],
                pager: pager_selector,
                altRows: true,
                //toppager: true,

                multiselect: false,
                //multikey: "ctrlKey",
                multiboxonly: true,

                loadComplete: function () {
                    var table = this;
                    setTimeout(function () {
                        styleCheckbox(table);

                        updateActionIcons(table);
                        updatePagerIcons(table);
                        enableTooltips(table);
                    }, 0);
                },

                editurl: "${contextPath}/static/ace/dummy.php",//nothing is saved
                caption: "烟草客户信息",
                jsonReader: {
                    root: "recordList",
                    page: "currentPage",
                    total: "pageCount",
                    records: "recordCount"
                }
                //,autowidth: true,


                /**
                 ,
                 grouping:true,
                 groupingView : {
				 groupField : ['name'],
				 groupDataSorted : true,
				 plusicon : 'fa fa-chevron-down bigger-110',
				 minusicon : 'fa fa-chevron-up bigger-110'
			},
                 caption: "Grouping"
                 */

            });
            $(window).triggerHandler('resize.jqGrid');//trigger window resize to make the grid get the correct size


            //enable search/filter toolbar
            //jQuery(grid_selector).jqGrid('filterToolbar',{defaultSearch:true,stringResult:true})
            //jQuery(grid_selector).filterToolbar({});


            //switch element when editing inline
            function aceSwitch(cellvalue, options, cell) {
                setTimeout(function () {
                    $(cell).find('input[type=checkbox]')
                        .addClass('ace ace-switch ace-switch-5')
                        .after('<span class="lbl"></span>');
                }, 0);
            }

            function changeCgtCust(cellvalue, options, cell) {
                var template = '<shiro:hasPermission name="CLOUDERPCLIENTELETOBACCO:AUTHORIZATION"><span class="ace-icon fa fa-flag bigger-120 green" onclick="javascript:authorization(\'' + cell.id + '\',1,\'' + options.gid + '\',\'' + cell.state + '\');" title="授权"></span></shiro:hasPermission><shiro:hasPermission name="CLOUDERPCLIENTELETOBACCO:CANELAUTHO"><span style="margin-left: 10px;" class="ace-icon fa fa-exclamation-triangle bigger-120 red" onclick="javascript:authorization(\'' + cell.id + '\',0,\'' + options.gid + '\',\'' + cell.state + '\');" title="取消授权"></span></shiro:hasPermission><shiro:hasPermission name="CLOUDERPCLIENTELETOBACCO:SENDMESSAGE"><span class="ace-icon fa fa-comment bigger-120 blue" style="margin-left: 10px;" onclick="javascript:sendCloudingMessage(\'' + cell.phone + '\',\'' + cell.username + '\');" title="发送小云消息"></span></shiro:hasPermission>';
                return template;
            }


            function synchronizationUnionpay(cellvalue, options, cell) {
                var color = "red"
                var title = "未同步到银联"
                if (cell.syncStatus == "01") {
                    color = "green"
                    title = "已同步到银联"
                }
                var id = "synchronizationUnionpay" + cell.id;
                var template = '<shiro:hasPermission name="CLOUDERPCLIENTELETOBACCO:SYNC"><span style="margin-left: 8px;" id="' + id + '" class="ace-icon fa fa-recycle bigger-120 ' + color + '" onclick="doSynchronizationUnionpay(\'' + cell.custCode + '\',\'' + id + '\')" title="' + title + '"></span></shiro:hasPermission>';
                return template;
            }

            function showUserInfo(cellvalue, options, cell) {
                var userName = cell.custName;
                //console.log(userName);

                if (userName == null || userName == "" || userName == 'null') {
                    userName = "无名客户"
                }
                template = '<a href="javascript:getUserInfo(\'' + cell.custCode + '\');">' + userName + '</a>';
                return template;
            }

            //enable datepicker
            function pickDate(cellvalue, options, cell) {
                setTimeout(function () {
                    $(cell).find('input[type=text]')
                        .datepicker({format: 'yyyy-mm-dd', autoclose: true});
                }, 0);
            }


            //navButtons
            jQuery(grid_selector).jqGrid('navGrid', pager_selector,
                { 	//navbar options
                    edit: false,
                    editicon: 'ace-icon fa fa-pencil blue',
                    add: false,
                    addicon: 'ace-icon fa fa-plus-circle purple',
                    del: false,
                    delicon: 'ace-icon fa fa-trash-o red',
                    search: false,
                    searchicon: 'ace-icon fa fa-search orange',
                    refresh: true,
                    refreshicon: 'ace-icon fa fa-refresh green',
                    view: false,
                    viewicon: 'ace-icon fa fa-search-plus grey',
                },
                {
                    //edit record form
                    //closeAfterEdit: true,
                    //width: 700,
                    recreateForm: true,
                    beforeShowForm: function (e) {
                        var form = $(e[0]);
                        form.closest('.ui-jqdialog').find('.ui-jqdialog-titlebar').wrapInner('<div class="widget-header" />')
                        style_edit_form(form);
                    }
                },
                {
                    //new record form
                    //width: 700,
                    closeAfterAdd: true,
                    recreateForm: true,
                    viewPagerButtons: false,
                    beforeShowForm: function (e) {
                        var form = $(e[0]);
                        form.closest('.ui-jqdialog').find('.ui-jqdialog-titlebar')
                            .wrapInner('<div class="widget-header" />')
                        style_edit_form(form);
                    }
                },
                {
                    //delete record form
                    recreateForm: true,
                    beforeShowForm: function (e) {
                        var form = $(e[0]);
                        if (form.data('styled')) return false;

                        form.closest('.ui-jqdialog').find('.ui-jqdialog-titlebar').wrapInner('<div class="widget-header" />')
                        style_delete_form(form);

                        form.data('styled', true);
                    },
                    onClick: function (e) {
                        //alert(1);
                    }
                },
                {
                    //search form
                    recreateForm: true,
                    afterShowSearch: function (e) {
                        var form = $(e[0]);
                        form.closest('.ui-jqdialog').find('.ui-jqdialog-title').wrap('<div class="widget-header" />')
                        style_search_form(form);
                    },
                    afterRedraw: function () {
                        style_search_filters($(this));
                    }
                    ,
                    multipleSearch: true,
                    /**
                     multipleGroup:true,
                     showQuery: true
                     */
                },
                {
                    //view record form
                    recreateForm: true,
                    beforeShowForm: function (e) {
                        var form = $(e[0]);
                        form.closest('.ui-jqdialog').find('.ui-jqdialog-title').wrap('<div class="widget-header" />')
                    }
                }
            )


            function style_edit_form(form) {
                //enable datepicker on "sdate" field and switches for "stock" field
                form.find('input[name=sdate]').datepicker({format: 'yyyy-mm-dd', autoclose: true})

                form.find('input[name=stock]').addClass('ace ace-switch ace-switch-5').after('<span class="lbl"></span>');
                //don't wrap inside a label element, the checkbox value won't be submitted (POST'ed)
                //.addClass('ace ace-switch ace-switch-5').wrap('<label class="inline" />').after('<span class="lbl"></span>');


                //update buttons classes
                var buttons = form.next().find('.EditButton .fm-button');
                buttons.addClass('btn btn-sm').find('[class*="-icon"]').hide();//ui-icon, s-icon
                buttons.eq(0).addClass('btn-primary').prepend('<i class="ace-icon fa fa-check"></i>');
                buttons.eq(1).prepend('<i class="ace-icon fa fa-times"></i>')

                buttons = form.next().find('.navButton a');
                buttons.find('.ui-icon').hide();
                buttons.eq(0).append('<i class="ace-icon fa fa-chevron-left"></i>');
                buttons.eq(1).append('<i class="ace-icon fa fa-chevron-right"></i>');
            }

            function style_delete_form(form) {
                var buttons = form.next().find('.EditButton .fm-button');
                buttons.addClass('btn btn-sm btn-white btn-round').find('[class*="-icon"]').hide();//ui-icon, s-icon
                buttons.eq(0).addClass('btn-danger').prepend('<i class="ace-icon fa fa-trash-o"></i>');
                buttons.eq(1).addClass('btn-default').prepend('<i class="ace-icon fa fa-times"></i>')
            }

            function style_search_filters(form) {
                form.find('.delete-rule').val('X');
                form.find('.add-rule').addClass('btn btn-xs btn-primary');
                form.find('.add-group').addClass('btn btn-xs btn-success');
                form.find('.delete-group').addClass('btn btn-xs btn-danger');
            }

            function style_search_form(form) {
                var dialog = form.closest('.ui-jqdialog');
                var buttons = dialog.find('.EditTable')
                buttons.find('.EditButton a[id*="_reset"]').addClass('btn btn-sm btn-info').find('.ui-icon').attr('class', 'ace-icon fa fa-retweet');
                buttons.find('.EditButton a[id*="_query"]').addClass('btn btn-sm btn-inverse').find('.ui-icon').attr('class', 'ace-icon fa fa-comment-o');
                buttons.find('.EditButton a[id*="_search"]').addClass('btn btn-sm btn-purple').find('.ui-icon').attr('class', 'ace-icon fa fa-search');
            }

            function beforeDeleteCallback(e) {
                var form = $(e[0]);
                if (form.data('styled')) return false;

                form.closest('.ui-jqdialog').find('.ui-jqdialog-titlebar').wrapInner('<div class="widget-header" />')
                style_delete_form(form);

                form.data('styled', true);
            }

            function beforeEditCallback(e) {
                var form = $(e[0]);
                form.closest('.ui-jqdialog').find('.ui-jqdialog-titlebar').wrapInner('<div class="widget-header" />')
                style_edit_form(form);
            }


            //it causes some flicker when reloading or navigating grid
            //it may be possible to have some custom formatter to do this as the grid is being created to prevent this
            //or go back to default browser checkbox styles for the grid
            function styleCheckbox(table) {
                /**
                 $(table).find('input:checkbox').addClass('ace')
                 .wrap('<label />')
                 .after('<span class="lbl align-top" />')


                 $('.ui-jqgrid-labels th[id*="_cb"]:first-child')
                 .find('input.cbox[type=checkbox]').addClass('ace')
                 .wrap('<label />').after('<span class="lbl align-top" />');
                 */
            }


            //unlike navButtons icons, action icons in rows seem to be hard-coded
            //you can change them like this in here if you want
            function updateActionIcons(table) {
                /**
                 var replacement =
                 {
                     'ui-ace-icon fa fa-pencil' : 'ace-icon fa fa-pencil blue',
                     'ui-ace-icon fa fa-trash-o' : 'ace-icon fa fa-trash-o red',
                     'ui-icon-disk' : 'ace-icon fa fa-check green',
                     'ui-icon-cancel' : 'ace-icon fa fa-times red'
                 };
                 $(table).find('.ui-pg-div span.ui-icon').each(function(){
				var icon = $(this);
				var $class = $.trim(icon.attr('class').replace('ui-icon', ''));
				if($class in replacement) icon.attr('class', 'ui-icon '+replacement[$class]);
			})
                 */
            }

            //replace icons with FontAwesome icons like above
            function updatePagerIcons(table) {
                var replacement =
                    {
                        'ui-icon-seek-first': 'ace-icon fa fa-angle-double-left bigger-140',
                        'ui-icon-seek-prev': 'ace-icon fa fa-angle-left bigger-140',
                        'ui-icon-seek-next': 'ace-icon fa fa-angle-right bigger-140',
                        'ui-icon-seek-end': 'ace-icon fa fa-angle-double-right bigger-140'
                    };
                $('.ui-pg-table:not(.navtable) > tbody > tr > .ui-pg-button > .ui-icon').each(function () {
                    var icon = $(this);
                    var $class = $.trim(icon.attr('class').replace('ui-icon', ''));

                    if ($class in replacement) icon.attr('class', 'ui-icon ' + replacement[$class]);
                })
            }

            function enableTooltips(table) {
                $('.navtable .ui-pg-button').tooltip({container: 'body'});
                $(table).find('.ui-pg-div').tooltip({container: 'body'});
            }

            //var selr = jQuery(grid_selector).jqGrid('getGridParam','selrow');

            $(document).one('ajaxloadstart.page', function (e) {
                $.jgrid.gridDestroy(grid_selector);
                $('.ui-jqdialog').remove();
            });
        });
    });
</script>
<script src="${contextPath}/static/system/js/common/vue.js"></script>
<script src="${contextPath}/static/layer/layer.js"></script>
<script type="text/javascript" src="${contextPath}/static/statistics/js/jquery.mockjax.js"></script>
<script type="text/javascript" src="${contextPath}/static/statistics/js/jquery.autocomplete.js"></script>
<script type="text/javascript" src="${contextPath}/static/util/my-autocomplete.js"></script>
<script src="${contextPath}/static/statistics/js/bootstrap-datetimepicker.min.js"></script>
<script src="${contextPath}/static/statistics/js/bootstrap-datetimepicker.fr.js"></script>
<script src="${contextPath}/static/statistics/js/bootstrap-datetimepicker.zh-CN.js"></script>
<script type="text/javascript">
    /**
     * 搜索烟草客户信息
     */
    function searchCgtCust() {
        var quXianName = $("#quXianNameInput").val();
        var quDaoName = $("#quDaoNameInput").val();
        var KeHuJingLiName = $("#KeHuJingLiNameInput").val();
        var channelName = $("#channelNameInput").val();
        var slsmanName = $("#slsmanNameInput").val();
        var cityType = $("#cityTypeInput").val();
        var orderLevel = $("#orderLevelInput").val();
        var syncState = $("#syncStateInput").val();
        var firstBindCarTime = $("#firstBindCarTimeInput").val();
        var firstPayOrderTime = $("#firstPayOrderTimeInput").val();
        var timeType = $("#timeTypeInput").val();
        var isBankCar = $("#isBankCarInout").val();
        var isPay = $("#isPayInout").val();
        var isDingYan = $("#isDingYanInout").val();
        var isExp = $("#isExpInout").val();
        //var parentDepartmentkey = $("#id_parentDepartmentkey_name").val();

        var filters = {
            "rules": [{
                "field": "channelName",
                "data": channelName
            }, {
                "field": "slsmanName",
                "data": slsmanName
            }, {
                "field": "syncState",
                "data": syncState
            }, {
                "field": "quXianName",
                "data": quXianName == undefined ? "" : quXianName
            }, {
                "field": "quDaoName",
                "data": quDaoName == undefined ? "" : quDaoName
            }, {
                "field": "KeHuJingLiName",
                "data": KeHuJingLiName == undefined ? "" : KeHuJingLiName
            }, {
                "field": "firstBindCarTime",
                "data": firstBindCarTime,
                "type": timeType,
            }, {
                "field": "firstPayOrderTime",
                "data": firstPayOrderTime,
                "type": timeType,
            }, {
                "field": "isBankCar",
                "data": isBankCar
            }, {
                "field": "isPay",
                "data": isPay
            }, {
                "field": "isDingYan",
                "data": isDingYan
            }, {
                "field": "isExp",
                "data": isExp
            }, {
                "field": "cityType",
                "data": cityType
            }, {
                "field": "orderLevel",
                "data": orderLevel
            }]
        };
        jQuery("#grid-table").jqGrid('setGridParam', {
            postData: {
                "filters": JSON.stringify(filters) //"{'rules' : [{'field' : 'shopName','data' : "+shopName+"},{'field' : 'state','data' : "+state+"}]}"
            }
        }).trigger("reloadGrid");
    }


    /**
     * 导出Excel
     */
    var exportExcel = function () {

        var quXianName = $("#quXianNameInput").val();
        var quDaoName = $("#quDaoNameInput").val();
        var KeHuJingLiName = $("#KeHuJingLiNameInput").val();
        var channelName = $("#channelNameInput").val();
        var slsmanName = $("#slsmanNameInput").val();
        var cityType = $("#cityTypeInput").val();
        var orderLevel = $("#orderLevelInput").val();
        var syncState = $("#syncStateInput").val();
        var firstBindCarTime = $("#firstBindCarTimeInput").val();
        var firstPayOrderTime = $("#firstPayOrderTimeInput").val();
        var timeType = $("#timeTypeInput").val();
        var isBankCar = $("#isBankCarInout").val();
        var isPay = $("#isPayInout").val();
        var isDingYan = $("#isDingYanInout").val();
        var isExp = $("#isExpInout").val();

        var filters = {
            "rules": [{
                "field": "channelName",
                "data": channelName
            }, {
                "field": "slsmanName",
                "data": slsmanName
            }, {
                "field": "syncState",
                "data": syncState
            }, {
                "field": "quXianName",
                "data": quXianName == undefined ? "" : quXianName
            }, {
                "field": "quDaoName",
                "data": quDaoName == undefined ? "" : quDaoName
            }, {
                "field": "KeHuJingLiName",
                "data": KeHuJingLiName == undefined ? "" : KeHuJingLiName
            }, {
                "field": "firstBindCarTime",
                "data": firstBindCarTime,
                "type": timeType,
            }, {
                "field": "firstPayOrderTime",
                "data": firstPayOrderTime,
                "type": timeType,
            }, {
                "field": "isBankCar",
                "data": isBankCar
            }, {
                "field": "isPay",
                "data": isPay
            }, {
                "field": "isDingYan",
                "data": isDingYan
            }, {
                "field": "isExp",
                "data": isExp
            }, {
                "field": "cityType",
                "data": cityType
            }, {
                "field": "orderLevel",
                "data": orderLevel
            }]
        };

        $('#exportExcelData-filters').val(JSON.stringify(filters));


        $("#exportExcel").submit();

    }


    function authorization(id, flag, gid, state) {
        //$.jgrid.info_dialog("提示：", "请选择一条信息", $.jgrid.edit);
        var message = "";
        if (flag == 1) {
            if (state == 1) {
                $.jgrid.info_dialog("提示：", "当前用户已经授权");
                return;
            }
            message = "确定要授权吗？"
        } else if (flag == 0) {
            if (state == 0) {
                $.jgrid.info_dialog("提示：", "当前用户已经取消授权");
                return;
            }
            message = "确定要取消授权吗？"
        }
        if (window.confirm(message)) {
            $.ajax({
                url: '${contextPath}/sys/clouderp/accreditCgtCust',
                data: {
                    id: id,
                    flag: flag,
                },
                type: 'POST',
                dataType: 'json',
                success: function (data) {

                    if (data.success) {
                        $("#" + gid).trigger('reloadGrid');
                    } else {
                        $.jgrid.info_dialog("提示：", data.message);
                    }
                },
                error: function (error) {
                    $.jgrid.info_dialog("提示：", "服务器错误，稍后重试");
                }
            });
        }

    }

    function sendCloudingMessage(phone, username) {
        $("#usernameSpan").html(username);
        $("#sendCloudingMessagePhone").val(phone);
        $("#sendCloudingMessageModal").modal('show');
    }

    function sendCloudingMessageConfrim() {
        var content = $("#sendCloudingMessagecontent").val();
        if (content.trim() == "") {
            $("#tishiP").attr("style", "color:red");
            $("#sendCloudingMessagecontent").focus();
            return;
        }
        $("#confrimBtn").html("正在发送...");
        $("#confrimBtn").attr("onclick", "javascript:void(0);");
        $.ajax({
            url: '${contextPath}/sys/clouderp/sendCloudingMessage',
            data: {
                phone: $("#sendCloudingMessagePhone").val(),
                content: content,
            },
            type: 'POST',
            dataType: 'json',
            success: function (data) {
                $("#sendCloudingMessageModal").modal('hide');
                $.jgrid.info_dialog("提示：", data.message);
                $("#confrimBtn").html("确定");
                $("#confrimBtn").attr("onclick", "sendCloudingMessageConfrim()");
            },
            error: function (error) {
                $("#sendCloudingMessageModal").modal('hide');
                $.jgrid.info_dialog("提示：", "服务器错误，稍后重试");
                $("#confrimBtn").html("确定");
                $("#confrimBtn").attr("onclick", "sendCloudingMessageConfrim()");
            }
        });
    }

    var app = new Vue({
        el: '#app',
        data: {
            basicInfo: {
                channelName: '--', //营销机构
                orgCode: '--', //营销机构
                slsmanName: '--', //客户经理
                custName: '--', //客户名称
                custCode: '--', //专卖证号
                custPassword: '--', //密码
                orderDateStr: '--', //订烟日
                orderBeginTimeStr: '--', //订烟起始时间
                orderEndTimeStr: '--', //订烟结束时间
                nextOrderDateStr: '--', //下一订烟日
                beginDateStr: '--', //订烟开始日期
                endDateStr: '--', //订烟结束日期
                custAddr: '--' //客户地址

            },
            merchant: {
                merchantCode: '--',
                merchantName: '--',
                merchantId: '--',
                bankCode: '--',
            },
            authorizationInfoList: [
                {
                    username: '--',
                    phone: '--',
                    stateStr: '--',
                    stateDateStr: '--', //修改时间
                    createDateStr: '--' //创建时间
                }, {
                    username: '--',
                    phone: '--',
                    stateStr: '--',
                    stateDateStr: '--', //修改时间
                    createDateStr: '--' //创建时间
                }
            ],
            bankInfoList: [],
            addBankInfo: {
                tradeSubType: 'DK',
                merId: "", //返回的merId
                userId: '770',
                customerId: "", //选择的csutCode
                accNo: "",
                name: "",
                certCode: "",
                nbr: "",
                cvn2: "",
                expireDate: "",
                cardType: "",
                smsCode: "123456",
                bankName: '',
                sign: 'xxx'

            },
        },
        methods: {
            showBangKaModal: function () {
                layer.load(1)
                $.ajax({
                    url: '${contextPath}/supermarket/httpPost',
                    type: 'post',
                    dataType: 'json',
                    data: {
                        url: "http://app1:23912/clouderp-cgt-order-rest/api/cgt/order/getMerchant",
                        stringMap: {
                            custCode: app.addBankInfo.customerId
                        }
                    },
                    success: function (data) {
                        layer.closeAll('loading')
                        //console.log(data)
                        if (data.code != '000') {
                            layer.msg(data.msg)
                            return;
                        }
                        app.addBankInfo.merId = data.data.merchantCode
                        //console.log(merchantCode)
                        $('#myModal').modal('show');
                    }
                    ,
                    error: function (error) {
                        layer.closeAll('loading')
                        layer.msg('网络错误')
                    }
                })
            },
            selectBankInfo: function () {
                var acc = app.addBankInfo.accNo
                if (acc.length < 6) {
                    return
                }
                $.ajax({
                    url: '${contextPath}/supermarket/httpPost',
                    type: 'post',
                    dataType: 'json',
                    data: {
                        url: "http://10.95.0.233:23912/clouderp-pay-rest/api/pay/getBankCardList",
                        stringMap: {
                            cardBin: acc.substr(0, 6)
                        }
                    },
                    success: function (data) {
                        app.addBankInfo.bankName = ''
                        app.addBankInfo.cardType = ''
                        //console.log(data)
                        if (data.code != '000') {
                            layer.msg(data.msg)
                            return;
                        }
                        var bankInfos = data.data
                        if (bankInfos.length != 1) {
                            layer.msg("输入有误，获取不到开户行")
                            return;
                        }

                        var bankInfo = bankInfos[0]
                        app.addBankInfo.bankName = bankInfo.bankName
                        app.addBankInfo.cardType = bankInfo.cardKind
                    }
                    ,
                    error: function (error) {
                        layer.msg("网络错误，获取开户行失败")
                    }
                })
            },
            submitAddBankCar: function () {
                //console.log(app.addBankInfo)
                if (app.addBankInfo.cardType == '01') {
                    app.addBankInfo.expireDate = app.addBankInfo.expireDate.substr(2, 4) + app.addBankInfo.expireDate.substr(0, 2)
                }

                layer.load(1)
                $.ajax({
                    url: '${contextPath}/sys/clouderp/bindBankCard',
                    type: 'post',
                    dataType: 'json',
                    data: {
                        stringMap: app.addBankInfo
                    },
                    success: function (data) {
                        layer.closeAll('loading')
                        //console.log(data)
                        if (data.code != '000') {
                            layer.msg(data.msg)
                            return;
                        }
                        layer.msg('绑卡成功')
                        $('#myModal').modal('hide');
                        var customerId = app.addBankInfo.customerId;

                        $.ajax({
                            url: '${contextPath}/sys/clouderp/getUserInfo?custCode=' + customerId,
                            // async : false,
                            success: function (data) {
                                if (data.success) {
                                    var result = data.data;
                                    console.log(result)
                                    app.basicInfo = result.basicInfo;
                                    app.authorizationInfoList = result.authorizationInfoList;
                                    app.bankInfoList = result.bankInfoList;
                                    if (result.merchant == null || result.merchant == undefined) {
                                        app.merchant = {
                                            merchantCode: '',
                                            merchantName: '',
                                            merchantId: '',
                                            bankCode: '',
                                        }
                                    } else {
                                        app.merchant = result.merchant
                                    }

                                } else {
                                    $.jgrid.info_dialog("提示：", data.message);
                                }

                            },
                            error: function (error) {
                                $.jgrid.info_dialog("提示：", "服务器异常，稍后再试");
                            }

                        });

                        app.addBankInfo.name = '';
                        app.addBankInfo.certCode = '';
                        app.addBankInfo.accNo = '';
                        app.addBankInfo.bankName = '';
                        app.addBankInfo.expireDate = '';
                        app.addBankInfo.nbr = '';
                        app.addBankInfo.cvn2 = '';
                    }
                    ,
                    error: function (error) {
                        layer.closeAll('loading')
                        layer.msg('网络错误')
                    }
                })
            }
        }
    })

    var getUserInfo = function (custCode) {
        layer.load(1);
        console.log('----- getUserInfo ---------');
        app.addBankInfo.customerId = custCode;

        /*    $("#userInfoContent").removeClass("hide")
            layer.open({
                type: 1,
                title: '客户信息',
                closeBtn: 1,
                shadeClose: true,
                maxmin: true,
                area: ['1100px', '600px'],
                skin: 'yourclass',
                content: $("#userInfoContent"),
                end: function () {
                    $("#userInfoContent").addClass("hide")
                }
            });
            return;*/
        $.ajax({
            url: '${contextPath}/sys/clouderp/getUserInfo?custCode=' + custCode,
            // async : false,
            type: 'post',
            success: function (data) {
                layer.closeAll('loading');
                console.log(data)
                if (data.success) {
                    var result = data.data;
                    console.log(result)
                    app.basicInfo = result.basicInfo;
                    console.log(app.basicInfo)
                    app.authorizationInfoList = result.authorizationInfoList;
                    console.log(app.authorizationInfoList)
                    app.bankInfoList = result.bankInfoList;
                    console.log(app.bankInfoList)

                    console.log(result.merchant)
                    if (result.merchant == null || result.merchant == undefined) {
                        app.merchant = {
                            merchantCode: '',
                            merchantName: '',
                            merchantId: '',
                            bankCode: '',
                        }
                    } else {
                        app.merchant = result.merchant
                    }
                    // $("#userInfoModal").modal("show");
                    $("#userInfoContent").removeClass("hide")
                    layer.open({
                        type: 1,
                        title: '客户信息',
                        closeBtn: 1,
                        shadeClose: true,
                        maxmin: true,
                        area: ['600px', '300px'],
                        skin: 'yourclass',
                        content: $("#userInfoContent"),
                        end: function () {
                            $("#userInfoContent").addClass("hide")
                        }
                    });

                } else {
                    $.jgrid.info_dialog("提示：", data.message);
                }

            },
            error: function (error) {
               console.log(error)
                layer.closeAll('loading');
                $.jgrid.info_dialog("提示：", "服务器异常，稍后再试");
            }

        })

    }

    var doSynchronizationUnionpay = function (custCode, iconId) {
        // layer.msg(custCode);
        layer.load(1);
        $.ajax({
            url: '${contextPath}/sys/clouderp/doSynchronizationUnionpay',
            data: {
                custCode: custCode,
            },
            type: 'POST',
            //async: false,
            dataType: 'json',
            success: function (data) {
                layer.closeAll('loading');
                layer.msg(data.message);
                if (data.success) {
                    var icon = $("#" + iconId)
                    icon.removeClass("red");
                    icon.removeClass("green");
                    icon.addClass("green");
                    icon.attr("title", "已同步到银联")
                }

            },
            error: function (error) {
                layer.closeAll('loading');
                layer.msg("服务器异常，稍后再试");
            }
        })
    }

    var selectEmpNameToSelected = function (channelName) {
        $.ajax({
            url: '${contextPath}/checking/selectEmpNameToSelected?channelName=' + channelName,
            success: function (data) {
                if (data.success) {
                    var countries = data.data
                    $('#KeHuJingLiNameInput').autocomplete({
                        lookup: countries,
                        onSelect: function (suggestion) {
                            //console.log('You selected: ' + suggestion.value + ', ' + suggestion.data);
                        },
                        width: 200,
                        minChars: 0,
                    });
                }
            }
        })
    }
    selectEmpNameToSelected('')

    var selectChannelNameToSelected = function (quXianName) {
        $.ajax({
            url: '${contextPath}/checking/selectChannelNameToSelected?quXianName=' + quXianName,
            success: function (data) {
                if (data.success) {
                    var countries = data.data
                    $('#quDaoNameInput').autocomplete({
                        lookup: countries,
                        onSelect: function (suggestion) {
                            //alert('You selected: ' + suggestion.value + ', ' + suggestion.data);
                            selectEmpNameToSelected(suggestion.value)
                        },
                        width: 200,
                        minChars: 0,
                    });
                }
            }
        })
    }
    selectChannelNameToSelected('')

    $.ajax({
        url: '${contextPath}/checking/selectQuXianNameToSelected',
        success: function (data) {
            if (data.success) {
                var countries = data.data
                $('#quXianNameInput').autocomplete({
                    lookup: countries,
                    onSelect: function (suggestion) {
                        //alert('You selected: ' + suggestion.value + ', ' + suggestion.data);
                        selectChannelNameToSelected(suggestion.value)
                    },
                    width: 200,
                    minChars: 0,
                });
            }
        }
    });

    selectCityTypeToSelected('${contextPath}','#cityTypeInput', null);

    $('#firstBindCarTimeInput').datetimepicker({
        language: 'zh-CN',
        weekStart: 1,
        todayBtn: 1,
        autoclose: 1,
        todayHighlight: 1,
        startView: 2,
        forceParse: 0,
        minView: 2,
        showMeridian: 1,
        format: "yyyy-mm-dd",
        //startDate:new Date(),
    });

    $('#firstPayOrderTimeInput').datetimepicker({
        language: 'zh-CN',
        weekStart: 1,
        todayBtn: 1,
        autoclose: 1,
        todayHighlight: 1,
        startView: 2,
        forceParse: 0,
        minView: 2,
        showMeridian: 1,
        format: "yyyy-mm-dd",
        //startDate:new Date(),
    });

    var uploadExcelBindCar = function () {
        $("#uplaodExcelFileContent").removeClass("hide")
        this.payQrCodeModalId = layer.open({
            type: 1,
            title: '上传客户信息文件',
            closeBtn: 1,
            area: ['300px', '300px'],
            skin: 'yourclass',
            content: $("#uplaodExcelFileContent"),
            end: function () {
                $("#uplaodExcelFileContent").addClass("hide")
            }
        });
    }

    var uploadExcel = function () {
        var excel = $("[name = 'excelInput']:input")[0].files[0];

        //console.log(excel.name.substr(excel.name.lastIndexOf('.')))
        //console.log(excel.size)

        if (excel == undefined) {
            layer.msg("请选择excel文件")
            return
        }
        if (excel.name.substr(excel.name.lastIndexOf('.')) != '.xls') {
            layer.msg("选择的文件不是excel类型")
            return
        }
        if (excel.size > 1048576) {
            layer.msg("选择的excel大于1Mb")
            return
        }
        var fm = new FormData();
        fm.append('excel', excel);
        layer.load(1)
        $.ajax(
            {
                url: '${contextPath}/page/uploadExcel',
                type: 'POST',
                data: fm,
                contentType: false, //禁止设置请求类型
                processData: false, //禁止jquery对DAta数据的处理,默认会处理
                //禁止的原因是,FormData已经帮我们做了处理
                success: function (data) {
                    //测试是否成功
                    //但需要你后端有返回值
                    //console.log(data);
                    if (data.success) {
                        //console.log(data.data);
                        $('#getResultFileNameInput').val(data.data)
                        layer.msg('上传成功--请保存文件名，稍后获取结果');
                    } else {
                        layer.msg('上传失败，稍后再试');
                    }
                    layer.closeAll('loading')
                },
                error: function (error) {
                    layer.msg("网络连接失败");
                    layer.closeAll('loading')
                }
            }
        );
    }

    var getUploadResult = function () {
        var fileName = $('#getResultFileNameInput').val();
        if (fileName == "") {
            layer.msg("请输入要获取的文件名称")
            $('#getResultFileNameInput').focus()
            return
        }

        if (fileName.substr(fileName.lastIndexOf('.')) != '.xls') {
            layer.msg("要获取的文件名称不对，请确认输入")
            $('#getResultFileNameInput').focus()
            return
        }
        layer.load(1)
        $.ajax(
            {
                url: '${contextPath}/page/examineUploadExcelResultIsExists',
                type: 'POST',
                data: {
                    resultFileName: fileName,
                },
                dataType: 'json',
                success: function (data) {
                    layer.closeAll('loading')
                    if (!data.success) {
                        layer.msg('文件没有找到或者正在处理，请稍后再试');
                    } else {
                        $('#getUploadExcelResultForm').submit()
                    }

                },
                error: function (error) {
                    //console.log(error)
                    layer.msg("网络连接失败");
                    layer.closeAll('loading')
                }
            }
        );
    }


    var selectOrderLevelToSelected = function () {
        $.ajax({
            url: '${contextPath}/checking/selectOrderLevelToSelected',
            success: function (data) {
                if (data.success) {
                    var countries = data.data
                    $('#orderLevelInput').autocomplete({
                        lookup: countries,
                        onSelect: function (suggestion) {
                            //console.log('You selected: ' + suggestion.value + ', ' + suggestion.data);
                        },
                        //width: 200,
                        minChars: 0,
                    });
                }
            }
        })
    };
    selectOrderLevelToSelected();
</script>
<%--
<script>
    (function() {
        if (navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i)) {
            window.location.hash =  '#page/clouderpClienteleTobaccomobile';
        }
        //window.location.href = 'http://baidu.com';
    })();
</script>--%>
